// 引入模块
const EventBus = require('../../utils/event-bus')

const mitt = require('mitt')
const emitter = mitt()

Page({
    data: {
        name: '李四'
    },

    handleAbcd(event) {
        console.log('handleAbcd', event)

        this.setData({
            name: event.detail
        })
    },

    fn1() {
        // 
        EventBus.$on('hello', (payload) => {
            console.log('hello1 的回调函数', payload)
        })

        // EventBus.$on('hello', () => {
        //     console.log('hello2 的回调函数')
        // })

        // emitter.on('abcd', (payload) => {
        //     console.log('abcd', payload)
        // })
    },

    fn2() {
        EventBus.$emit('hello', '张三')

        // emitter.emit('abcd', '张三')
    },

    fn3() {
        // 获取 world 组件的实例对象
        const worldIns = this.selectComponent('#my-world')
        console.log(worldIns)
        worldIns.setData({
            count: 100
        })
    }
})